package cn.buyclss.backend.service.impl;

import cn.buyclss.backend.entity.domain.SysLogEntity;
import cn.buyclss.backend.entity.domain.SysLogEntityExample;
import cn.buyclss.backend.entity.support.RespResult;
import cn.buyclss.backend.mapper.SysLogEntityMapper;
import cn.buyclss.backend.service.SysLogService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author: Cecurio
 * @create: 2019-03-14 9:40
 **/
@Service
public class SysLogServiceImpl implements SysLogService {
    @Autowired
    private SysLogEntityMapper sysLogMapper;


    @Override
    public void save(SysLogEntity sysLog) {
        sysLogMapper.insertSelective(sysLog);
    }

    @Override
    public RespResult pageShow(Integer pageIndex, Integer pageSize) {
        RespResult res = RespResult.successInstance();
        PageHelper.startPage(pageIndex, pageSize);
        SysLogEntityExample example = new SysLogEntityExample();
        List<SysLogEntity> sysLogEntityList = sysLogMapper.selectByExample(example);
        PageInfo<SysLogEntity> pageInfo= new PageInfo<SysLogEntity>(sysLogEntityList);
        res.putValue("logs",pageInfo);
        return res;
    }
}
